	//信使
	var Messager=function(selector){
		this.selector=selector;
	}
	Messager.prototype.url="./content.json";
	Messager.prototype.timer=null;
	Messager.prototype.count=0;
	
	Messager.prototype.content="<p>暂无消息</p>";
	Messager.prototype.delay=1000;
	Messager.prototype.init=function(){
		if(typeof this.selector == "undefined"){
			this.create();
		}
		var self=this;
		this.testing();
		this.timer=setInterval(function(event){
			self.testing();
		}, this.delay);
		$(".closeButton",this.selector).bind("click",function(event){
			self.focusClose();
		});
		$(".openButton",this.selector).bind("click",function(event){
			self.focusOpen();
		});
		//this.update();
	}
	Messager.prototype.create=function(){
		var html='';
		html+='<div class="ht-messager focusClose" id="messager">';
		html+='<div class="wrapper">';
		html+='<h4 class="title">消息提醒  <strong class="count">[0]</strong></h4>';
		html+='<div class="toolBar">';
		html+='<a class="button closeButton">关闭</a><a class="button openButton">打开</a>';
		html+='</div>';
		html+='<div class="content">';
		html+='<p>暂无内容</p>';
		html+='</div>';
		html+='</div>';
		html+='</div>';
		this.selector=$(html)
		$("body").append(this.selector);
	}
	Messager.prototype.update=function(){
		$(".content",this.selector).html(this.content);
		$(".count",this.selector).html("["+this.count+"]");
		ht.update($(".content",this.selector));
		if(this.count==0){
			this.focusClose();
		}else{
			this.focusOpen();
		}
	}
	Messager.prototype.testing=function(){
		var self=this;
		var options={}
		options.url=this.url;
		options.dataType="json"
		options.cache=false
		options.type="get"
		options.success=function(data, textStatus, jqXHR){
			
			var updateEnable=false;
			var content=data.data.content;
			var count=data.data.count;
			
			if(self.content!=content){
				updateEnable=true;
			}
			if(self.count!=count){
				updateEnable=true;
			}
			
			self.content=content;
			self.count=count;
			
			if(updateEnable){
				self.update();
			}
		},
		options.error=function(){
			$(".title",this.selector).html("刷新消息失败");
		}
		$.ajax(options);
	}
	Messager.prototype.focusOpen=function(){
		//console.log(11);
		$(this.selector).removeClass("focusClose");
		$(this.selector).addClass("focusOpen");
	}
	Messager.prototype.focusClose=function(){
		//console.log(22);
		$(this.selector).removeClass("focusOpen");
		$(this.selector).addClass("focusClose");
	}
	HTMLTurbo.control.Messager=Messager;